# coding: utf-8
'''
Created on May 23rd, 2011

@author: manux
'''

import unittest
from dao.DaoDamier import DaoDamier 

class Test(unittest.TestCase):

    def setUp(self):
        self.daoDamier = DaoDamier("niveau1")

    def tearDown(self):
        del self.daoDamier
    
    def test_chemin(self):
        self.assertEqual(self.daoDamier._chemin.split('/')[-3:-1],\
                         ['TheShinProject', 'DAO'])

    def test_height(self):
        self.assertEqual(self.daoDamier.height, 8)

    def test_width(self):
        self.assertEqual(self.daoDamier.width, 10)
    
    def test_len_terrainType(self):
        self.assertEqual((self.daoDamier.height * self.daoDamier.width),\
                         len(self.daoDamier.terrainType))
    
    def test_cases_eau(self):
        for x in ('A6', 'A7', 'A8',\
                  'B6', 'B7', 'B8',\
                  'C5', 'C6', 'C7',\
                  'D5', 'D6', 'D7',\
                  'E5', 'E6'):
            self.assertEqual(self.daoDamier.terrainType[x][:-1], 'Eau')
    
    def test_cases_herbe(self):
        for x in ('A1', 'A2', 'A3', 'A4', 'A5',\
                  'B1', 'B2', 'B3', 'B4', 'B5',\
                  'C1', 'C2', 'C3', 'C4', 'C8',\
                  'D1', 'D2', 'D3', 'D8',\
                  'E7', 'E8',\
                  'F1', 'F5', 'F6', 'F7', 'F8',\
                  'G1', 'G5', 'G6', 'G7', 'G8',\
                  'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8',\
                  'I1', 'I2', 'I3', 'I4', 'I5',\
                  'J1', 'J2', 'J3', 'J4', 'J5'):
            self.assertEqual(self.daoDamier.terrainType[x][:-1], 'Herbe')
    
    def test_cases_rocher(self):
        for x in ('E1',\
                  'G4',\
                  'I6', 'I7', 'I8',\
                  'J6', 'J7', 'J8'):
            self.assertEqual(self.daoDamier.terrainType[x][:-1], 'Rocher')
    
    def test_cases_sable(self):
        for x in ('D4',\
                  'E2', 'E3', 'E4',\
                  'F2', 'F3', 'F4',\
                  'G2', 'G3'):
            self.assertEqual(self.daoDamier.terrainType[x][:-1], 'Sable')


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()
